<template>
  <div>
    <div style="position: fixed;top: 0;left: 0;width: 100%;height:100%;background-color: #e6faff"></div>
    <div style="position: absolute;top: 50.5px;left: 0;width: 100%;height:120px;background-color:#00ccbb">
      <p style="font-size: 31px;font-weight:800;color: white;letter-spacing: 3px;margin-left: 300px;padding: 5px;font-style: italic">找工作</p>
      <p style="font-size: 31px;font-weight:800;color: white;letter-spacing: 3px;margin-left: 300px;font-style: italic">上树叶招聘</p>
    </div>
    <div style="position: fixed;top: 0;left: 0;width: 100%;height: 50.5px;background-color: #39494d">
      <h3 style="color: #00e3e6;letter-spacing: 3px;padding: 10px;margin-left: 260px">树叶招聘网</h3>
    </div>
    <div style="position: absolute;margin-top: 170px">
      <img src="../assets/true.jpg" width="307" height="814">
    </div>
<div>
  <MainMenu/>
</div>
    <div style="position: absolute;top: 173px;left:307px;height: 650px;overflow: auto">
      <el-table :data="employeeTableData" style="width: 1400px">
        <el-table-column label="公司" prop="firmname" />
        <el-table-column label="职位" prop="position" />
        <el-table-column label="薪资范围" prop="wage" />
        <el-table-column label="联系人" prop="contacts" />
        <el-table-column label="电话号码" prop="phone" />
        <el-table-column label="公司地址" prop="firmaddress"/>
        <el-table-column>
          <template #default="scope">
            <el-button size="default" type="success" @click=" handinresume(scope.row.id,user.account)">投简历</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div>
      <UserMenu/>
    </div>
  </div>
</template>

<style scoped>
ul {
  position: fixed;
  list-style-type: none;
  margin-left: 400px;
  padding: 0;
  overflow: hidden;
  background-color: #39494d;
}
li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}
li a:hover{
  color:#00e3e6 ;
}
.dropbtn {
  background-color: #4CAF50;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
  cursor: pointer;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown:hover .dropbtn {
  background-color: #3e8e41;
}
</style>
<script >

import axios from "axios";
import {computed,ref} from "vue";
import request from "@/Utils/request.js";
import UserMenu from "@/components/UserMenu.vue";
import MainMenu from "@/components/MainMenu.vue";
export default {
  data() {
    return {
      employeeTableData:[],
      user:localStorage.getItem("user")?JSON.parse(localStorage.getItem("user")):{},
      usermsg:localStorage.getItem("usermsg")?JSON.parse(localStorage.getItem("usermsg")):{},
    }
  },
  mounted(){
    request.get('/user/findall').then(res=>{
      this.employeeTableData=res
        }
    )
  },
  methods:{
    handinresume(id,applicantaccount){
      const name=this.usermsg[0]['name']
      const educational=this.usermsg[0]['position']
      const requestData = {
        firmname: this.employeeTableData[this.employeeTableData.length-1]["firmname"],
        position: this.employeeTableData[this.employeeTableData.length-1]["position"],
        wage: this.employeeTableData[this.employeeTableData.length-1]["wage"],
        contacts: this.employeeTableData[this.employeeTableData.length-1]["contacts"],
        phone: this.employeeTableData[this.employeeTableData.length-1]["phone"],
        firmaddress: this.employeeTableData[this.employeeTableData.length-1]["firmaddress"],
        account:this.employeeTableData[this.employeeTableData.length-1]["account"]
      };
        request.post('/user/ifresume',requestData ,
            {
              params:{
                id:id,
                applicantaccount:applicantaccount,
                applicant:name,
                educational:educational
              }
            },
            ).then(res=>{
              if(res === 0){
                this.$message.warning("您已投过该公司简历,请勿重复操作")
              }else {
                console.log(res)
                this.$message({
                  message:'操作完成',
                  type:'success'
                })
              }
        }).catch(err=>{
          console.log(err)
        })
    },
    exit(){
      localStorage.removeItem("user");
      this.$router.push('/login');
      this.$message({
        message:'退出成功!',
        type:'success'
      })
    }
  },
  components:{
    UserMenu,MainMenu,
  }
}
</script>
